﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using IHISCETeim.DAL;
using IHISCETeim.Model;
using IHISCETeim.Library;
using System.Data;


namespace IHISCETeim.BLL
{
    public  class VIPAgentExchangeController
    {
        public static int Add(VIPAgentExchangeInfo obj, List<VIPAgentExchangeDetailInfo> listDetail)
        {
            int AgentExID=VIPAgentExchangeDAL.Add(obj, listDetail);
            VIPAgentExchangeInfo exObj=GetList(AgentExID);
            if (AgentExID <= 0)
                return 0;
            SEMailListInfo emailObj = VIPEmailController.GetVIPAgentExchangeAddEmail(exObj);
            SEMailListDAL.Add(emailObj);
            return 1;//经销商添加，需要审核
        }

        public static bool Delete(int AgentExID)
        {

            return VIPAgentExchangeDAL.Delete(AgentExID);
        }

        public static List<VIPAgentExchangeDetailInfo> GetAllDetail(int AgentExID)
        {
            return  CBO.FillCollection<VIPAgentExchangeDetailInfo>( VIPAgentExchangeDAL.GetAllDetail(AgentExID));
        }
        public static VIPAgentExchangeInfo GetList(int AgentExID)
        {
            return CBO.FillObject<VIPAgentExchangeInfo>( VIPAgentExchangeDAL.GetList(AgentExID));
        }
        public static DataTable GetPagination(string WhereSql, int PageIndex, int PageSize, string Sort, ref int TotalCount)
        {
            return VIPAgentExchangeDAL.GetPagination(WhereSql, PageIndex, PageSize, Sort, ref  TotalCount);
        }
        public static int UpdateAudit(VIPAgentExchangeInfo obj, List<VIPAgentExchangeDetailInfo> listDetail)
        {
            return VIPAgentExchangeDAL.UpdateAudit(obj, listDetail);
        }
        public static bool UpdateReceipt(int AgentExID, DateTime ReceiptDate, string Remark)
        {
            return VIPAgentExchangeDAL.UpdateReceipt(AgentExID, ReceiptDate, Remark);
        }
        public static bool UpdateShipped(VIPAgentExchangeInfo obj)
        {
            return VIPAgentExchangeDAL.UpdateShipped(obj.AgentExID, obj.ShippedDate, obj.ExpressName, obj.ExpressDocNum, obj.RealName, obj.Tel, obj.Address, obj.Remark);
        }
    }
}
